There are three versions of the Allegro library: the normal optimised code, one with extra debugging support, and a profiling version. See the platform specific readme files for information about how to install and link with these alternative libs. Although you will obviously want to use the optimised library for the final version of your program, it can be very useful to link with the debug lib while you are working on it, because this will make debugging much easier, and includes assert tests that will help to locate errors in your code at an earlier stage. Allegro also contains some debugging helper functions:
#define DEBUGMODE
#include
...
void my_blitter(BITMAP *source, int flags)
{
int some_variables;
ASSERT(source != NULL);
ASSERT(flags & GAME_RUNNING);
...
}
See also: al_assert, TRACE, register_assert_handler.
Examples using this: expackf.
#define DEBUGMODE
#include
...
void my_blitter(BITMAP *source, int flags)
{
static int count_call = 0;
TRACE("my_blitter() called %d times.\n", count_call++);
...
}
See also: al_trace, ASSERT, register_trace_handler.
int show_but_continue(const char *text)
{
alert("Uh oh...", "Fasten your seat belts.", text,
"&Go on!", NULL, 'g', 0);
return 1;
}
...
register_assert(show_but_continue);
ASSERT(0); /* This won't crash the program now. */
See also: al_assert, ASSERT, register_trace_handler.
int network_broadcaster(const char *text)
{
int f;
for (int f = 0; f < connected_clients; f++)
send_msg_to_client(client[f], text);
return 0; /* Let normal tracing occur. */
}
...
register_trace_handler(network_broadcaster);
TRACE("Networked tracing activated\n");
See also: al_trace, TRACE, register_assert_handler.
You will usually want to use the ASSERT() macro instead of calling this function directly.
See also: ASSERT, al_trace, register_assert_handler.
See also: TRACE, al_assert, register_trace_handler.